// 列表
import { getSupplierList } from '@/api/supplier';
import { payBackList } from '@/api/payBack';
// 数据
import { deptList } from '@/api/select';
import { getDepartmentAll } from '@/api/config';
import { energyList } from '@/api/energy';
import { signUpList } from '@/api/signUp';
import { getOriginal } from '@/api/original';
import { getIssueInvoiceList, getOurTitleList, getIssueOurTitleList, getInvoiceProjectList, getInvoiceTypes } from '@/api/issueInvoice';
import { getAbandonList } from '@/api/invoiceAbandon';
import { getArrearsTransferList } from '@/api/arrearsTransfer';
import { getReimbursementList } from '@/api/reimbursement';
import { getLoanList } from '@/api/loan';
import { getModuleOurTitle } from '@/api/invoice';
import { getList } from '@/api/legal';
import { terminationList } from '@/api/termination';
import { getClientAdjustmentList, getLevelList } from '@/api/customer';
import { externalHarvestList } from '@/api/externalHarvest';

// filter
import { energyStatus, supplierCostBelong, accountTypeStatus, expeditedOptions } from '@/filters/status';
import { format } from '@/filters/date';
import { OUR_TITLE_MODULE, CURRENT_NODE_MODULE } from '@/utils/const';
import { paramsRangeFormat, paramsAryToStr } from '@/utils/paramsFormat';
import { commonOptions } from '@/utils/tools';
import { mapOptions } from '@/filters';
import options from '@/views/legal/module/options.js';
import { moneyFilter } from '@/filters/number';

// import { BUSINESS_TYPE } from '@/utils/const/process';
/**
 * @param {String} name 审批名称
 * @param {Object} fieldsProp 列表字段属性
 * @param {Function} api 列表接口
 * @param {Array} filterList 列表筛选
 * @param {Array} numberField 数字字段，用于设置统计字段
 *
 */
//  0: 合同审批  1: 付款申请 2:精力分配 3:签约内审 4:申请原件 5:开票申请
// 6:发票作废 7:员工报销 8:借款申请 9:还款申请 11:转交欠款 12:达人解约
// 13:客户额度申请  14:外采额度申请

const getOptions = (promiseList) => {
  return new Promise((resolve, reject) => {
    Promise.all(promiseList).then(res => {
      resolve(res);
    }).catch(() => {
      reject(false);
    });
  });
};
const filterListCache = {}; // 缓存筛选属性
const setPromiseAndMapArr = (optionsArr, promise, map) => {
  const needHttp = [];
  optionsArr.forEach((i) => {
    if (!filterListCache[i.name]) {
      needHttp.push(i);
    } else {
      console.log(`命中 ${i.name} 缓存`);
    }
  });
  needHttp.forEach((i, index) => {
    promise.push(i.fn(i.params));
    if (map) map[i.name] = index;
  });
};
export const createConfig = async(type) => {
  const ans = getConfigData(type);
  if (!ans) return null;
  if (type === 0) {
    // 合同审批
    const promise = [];
    const map = {};
    setPromiseAndMapArr([
      { name: 'getDepartmentAll', fn: getDepartmentAll },
      { name: 'getIssueOurTitleList', fn: getIssueOurTitleList }
    ], promise, map);
    if (promise.length) {
      const options = await getOptions(promise);
      if (map['getDepartmentAll'] !== undefined) filterListCache['getDepartmentAll'] = options[map['getDepartmentAll']].data;
      if (map['getIssueOurTitleList'] !== undefined) {
        options[map['getIssueOurTitleList']].data.forEach(i => {
          i.value = i.id;
          i.label = i.name;
          i.isStringVal = true;
        });
        filterListCache['getIssueOurTitleList'] = options[map['getIssueOurTitleList']].data;
      }
    }
    ans.filterList = [
      { keyword: 'contractCode', name: '合同编号', type: 'input', labelWidth: '99px' },
      { keyword: 'contractName', name: '项目名称', type: 'input', labelWidth: '99px' },
      { keyword: 'proposer', name: '申请人', type: 'input', labelWidth: '99px' },
      { keyword: 'creator', name: '创建人', type: 'input', labelWidth: '99px' },
      { keyword: 'departmentIdList', name: '申请人部门', type: 'cascaderSelectWithChild', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      { keyword: 'contractType', name: '合同类型', type: 'select', options: [...options.typeOptions] },
      { keyword: 'contractAmount', name: '合同金额', labelWidth: '99px', type: 'inputRange', isRequired: true, startPlaceholder: '最低金额', endPlaceholder: '最高金额', max: 999999999 },
      { keyword: 'oppCompany', name: '签约对方', type: 'input', labelWidth: '99px' },
      { keyword: 'contractSubject', name: '我方签约主体', type: 'select', options: filterListCache['getIssueOurTitleList'], placeholder: '签约主体' },
      { keyword: 'contractDate', name: '合作方式', type: 'select', options: [...options.dateTypeOptions] },
      { keyword: 'contractEffectDate', name: '合同有效期', type: 'rangeDate', timeType: 'daterange', labelWidth: '99px' }
    ];
  } else if (type === 1) {
    // 付款申请
    const promise = [];
    const map = {};
    setPromiseAndMapArr([
      { name: 'deptList', fn: deptList },
      { name: 'getDepartmentAll', fn: getDepartmentAll }
    ], promise, map);
    if (promise.length) {
      const options = await getOptions(promise);
      if (map['deptList'] !== undefined) {
        options[map['deptList']].data.forEach(i => {
          i.label = i.value; i.value = i.id;
        });
        filterListCache['deptList'] = options[map['deptList']].data;
      }
      if (map['getDepartmentAll'] !== undefined) filterListCache['getDepartmentAll'] = options[map['getDepartmentAll']].data;
    }

    ans.filterList = [
      { keyword: 'supplierNum', name: '单号', labelWidth: '96px', type: 'input' },
      { keyword: 'settleName', name: '结算名称', labelWidth: '96px', type: 'input' },
      { keyword: 'orderNum', name: '订单编号', labelWidth: '96px', type: 'input' },
      { keyword: 'supplier', name: '供应商名称', labelWidth: '96px', type: 'input' },
      { keyword: 'settleCreateUser', name: '结算单创建人', labelWidth: '96px', type: 'input' },
      { keyword: 'createUser', name: '审批单创建人', labelWidth: '96px', type: 'input' },
      { keyword: 'proposer', name: '审批单申请人', labelWidth: '96px', type: 'input' },
      { keyword: 'approvalUser', name: '审批单审批人', labelWidth: '96px', type: 'input' },
      { keyword: 'currentRole', name: '当前处理人', labelWidth: '96px', type: 'input' },
      { keyword: 'reviewNum', name: '审批单号', labelWidth: '96px', type: 'input' },
      { keyword: 'costNum', name: '成本编号', labelWidth: '96px', type: 'input' },
      { keyword: 'comment', name: '评论', type: 'input', labelWidth: '96px' },
      { keyword: 'approvalComment', name: '审批意见', type: 'input', labelWidth: '96px' },
      { keyword: 'settleAmount', labelWidth: '96px', name: '结算金额', type: 'inputRange' },
      { keyword: 'invioce', name: '发票', type: 'select', options: [
        { value: 0, label: '已取得' },
        { value: 1, label: '未取得' },
        { value: 2, label: '无需发票' },
        { value: 3, label: '财务统一申请' },
        { value: 4, label: '业务统一申请' }
      ] },
      { keyword: 'invioceStatus', name: '发票状态', type: 'select', options: [
        { value: 0, label: '已填写' },
        { value: 1, label: '未填写' }
      ] },
      {
        keyword: 'currentNode',
        name: '当前节点',
        type: 'loadMoreSelect',
        valueName: 'name',
        directShow: true,
        multiple: true,
        extendParams: { type: CURRENT_NODE_MODULE.SUPPLIER },
        labelName: 'name',
        placeholder: '当前节点',
        apiUrl: 'admin/common/currentNodes'
      },
      { keyword: 'proposerDepartment', name: '申请人部门', isSearch: true, type: 'select', options: filterListCache['deptList'] },
      { keyword: 'paymentBelong', name: '款项归属', type: 'cascaderSelectWithChild', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      { keyword: 'costBelong', name: '成本来源', type: 'select', options: [{ value: 0, label: '渠道订单' }, { value: 1, label: '项目订单' }, { value: 2, label: '商务订单' }, { value: 3, label: '营销授权' }, { value: 5, label: '项目渠道单' }] },
      { keyword: 'accountType', name: '账户类型', type: 'select', options: [{ value: 1, label: '第三方账户' }, { value: 2, label: '对公银行账户' }, { value: 3, label: '对公其他账户' }] },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      { keyword: 'planPayTime', labelWidth: '96px', name: '计划支付日期', timeType: 'daterange', type: 'rangeDate' },
      { keyword: 'actualPayTime', labelWidth: '96px', name: '实际支付日期', timeType: 'daterange', type: 'rangeDate' }

    ];
  } else if (type === 2) {
    // 9:精力分配
    if (!filterListCache['getDepartmentAll']) {
      const options = await getOptions([getDepartmentAll()]);
      filterListCache['getDepartmentAll'] = options[0].data;
    }
    ans.filterList = [
      // 输入框
      { keyword: 'energyNum', name: '审批单号', labelWidth: '70px', type: 'input' },
      { keyword: 'proposer', name: '当前处理人', labelWidth: '100px', type: 'input' },
      { keyword: 'currentNode', name: '当前节点', labelWidth: '70px', type: 'input' },
      { keyword: 'createUser', name: '创建人', labelWidth: '100px', type: 'input' },
      { keyword: 'comment', name: '评论', type: 'input', labelWidth: '100px' },
      { keyword: 'approvalComment', name: '审批意见', type: 'input', labelWidth: '100px' },
      // 下拉
      { keyword: 'status', name: '状态', type: 'select', options: commonOptions },
      { keyword: 'attributionMatrix', name: '所属部门', type: 'cascaderSelect', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      // 日期
      { keyword: 'monthTime', name: '月份', labelWidth: '70px', timeType: 'monthrange', type: 'rangeDate', format: 'yyyy/MM', startPlaceholder: '开始月份', endPlaceholder: '结束月份' },
      { keyword: 'createTime', name: '创建时间', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' }
    ];
  } else if (type === 3) {
    // 3:签约内审
    if (!filterListCache['getDepartmentAll']) {
      const options = await getOptions([getDepartmentAll()]);
      filterListCache['getDepartmentAll'] = options[0].data;
    }
    ans.filterList = [
      // 输入框
      { keyword: 'signUpNum', name: '审批单号', labelWidth: '70px', type: 'input' },
      { keyword: 'supplier', name: '供应商名称', labelWidth: '100px', type: 'input' },
      { keyword: 'agentName', name: '签单签约经纪', labelWidth: '70px', type: 'input' },
      { keyword: 'createUser', name: '创建人', labelWidth: '100px', type: 'input' },
      { keyword: 'currentNode', name: '当前节点', labelWidth: '70px', type: 'input' },
      { keyword: 'comment', name: '评论', type: 'input', labelWidth: '100px' },
      { keyword: 'approvalComment', name: '审批意见', type: 'input', labelWidth: '70px' },
      // 下拉
      { keyword: 'status', name: '状态', type: 'select', options: commonOptions },
      { keyword: 'departmentId', name: '所属部门', type: 'cascaderSelect', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      // 日期
      { keyword: 'signDate', name: '签约日期', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' },
      { keyword: 'createTime', name: '创建时间', labelWidth: '70px', timeType: 'daterange', type: 'rangeDate' }
    ];
  } else if (type === 4) {
    // 4:申请原件
    if (!filterListCache['getDepartmentAll']) {
      const options = await getOptions([getDepartmentAll()]);
      filterListCache['getDepartmentAll'] = options[0].data;
    }
    ans.filterList = [{ keyword: 'sn', name: '审批单号', labelWidth: '100px', type: 'input' },
      { keyword: 'projectName', name: '项目名称', labelWidth: '100px', type: 'input' },
      { keyword: 'applyRemark', name: '申请说明', labelWidth: '100px', type: 'input' },
      { keyword: 'createUser', name: '创建人', labelWidth: '100px', type: 'input' },
      { keyword: 'currentNode', name: '当前节点', labelWidth: '100px', type: 'input' },
      { keyword: 'proposer', name: '当前处理人', labelWidth: '100px', type: 'input' },
      { keyword: 'comment', name: '评论', type: 'input', labelWidth: '100px' },
      { keyword: 'approvalComment', name: '审批意见', type: 'input', labelWidth: '100px' },
      { keyword: 'status', name: '状态', type: 'select', options: commonOptions },
      { keyword: 'departmentId', name: '所属部门', type: 'cascaderSelect', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      { keyword: 'createTime', name: '创建时间', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' }
    ];
  } else if (type === 5) {
    // 5:开票申请
    const promise = [];
    const map = {};
    setPromiseAndMapArr([
      { name: 'getOurTitleList', fn: getOurTitleList, params: { isAll: true }},
      { name: 'getDepartmentAll', fn: getDepartmentAll },
      { name: 'getInvoiceProjectList', fn: getInvoiceProjectList, params: { isAll: true }},
      { name: 'getInvoiceTypes', fn: getInvoiceTypes, params: { isAll: true }}
    ], promise, map);

    if (promise.length) {
      const options = await getOptions(promise);

      if (map['getOurTitleList'] !== undefined) {
        options[map['getOurTitleList']].data.forEach(i => {
          i.label = i.name; i.value = i.id;
        });
        filterListCache['getOurTitleList'] = options[map['getOurTitleList']].data;
      }
      if (map['getDepartmentAll'] !== undefined) filterListCache['getDepartmentAll'] = options[map['getDepartmentAll']].data;
      if (map['getInvoiceProjectList'] !== undefined) {
        options[map['getInvoiceProjectList']].data.forEach(i => {
          i.label = i.name; i.value = i.id;
        });
        filterListCache['getInvoiceProjectList'] = options[map['getInvoiceProjectList']].data;
      }
      if (map['getInvoiceTypes'] !== undefined && options[map['getInvoiceTypes']]) {
        options[map['getInvoiceTypes']].data.forEach(i => {
          i.label = i.name; i.value = i.id;
        });
        filterListCache['getInvoiceTypes'] = options[map['getInvoiceTypes']].data;
      }
    }

    ans.filterList = [
      // 输入框
      { keyword: 'approvalNo', name: '审批单号', labelWidth: '85px', type: 'input' },
      { keyword: 'taxpayerName', name: '纳税人名称', labelWidth: '85px', type: 'input' },
      { keyword: 'amount', name: '含税金额', labelWidth: '85px', type: 'inputRange' },
      { keyword: 'proposer', name: '申请人', labelWidth: '85px', type: 'input' },
      { keyword: 'currentHandler', name: '当前处理人', labelWidth: '85px', type: 'input' },
      { keyword: 'creator', name: '创建人', labelWidth: '85px', type: 'input' },
      // 下拉
      { keyword: 'invoiceType', name: '发票类型', type: 'select', valueName: 'label', options: filterListCache['getInvoiceTypes'] },
      { keyword: 'project', name: '开票项目', type: 'select', valueName: 'label', options: filterListCache['getInvoiceProjectList'] },
      { keyword: 'ourTitle', name: '我方抬头', type: 'select', valueName: 'label', options: filterListCache['getOurTitleList'] },
      { keyword: 'status', name: '状态', type: 'select', options: commonOptions },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      { keyword: 'departmentId', name: '申请部门', type: 'cascaderSelectWithChild', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      // 日期
      { keyword: 'createTime', name: '创建时间', labelWidth: '85px', timeType: 'daterange', type: 'rangeDate' }
    ];
  } else if (type === 6) {
    // 6:发票作废
    if (!filterListCache['getDepartmentAll']) {
      const options = await getOptions([getDepartmentAll()]);
      filterListCache['getDepartmentAll'] = options[0].data;
    }
    ans.filterList = [
      { keyword: 'examineId', name: '审批单号', type: 'input' },
      { keyword: 'customerName', name: '纳税人名称', type: 'input' },
      { keyword: 'abandonRemark', name: '作废说明', type: 'input' },
      { keyword: 'proposer', name: '申请人', type: 'input' },
      { keyword: 'creator', name: '创建人', type: 'input' },
      // { keyword: 'currentNode', name: '当前节点', type: 'input' },
      { keyword: 'currentUser', name: '当前处理人', type: 'input' },
      { keyword: 'amount', name: '含税金额', type: 'inputRange' },
      { keyword: 'status', name: '状态', type: 'select', options: commonOptions },
      {
        keyword: 'currentNode',
        name: '当前节点',
        type: 'loadMoreSelect',
        valueName: 'name',
        directShow: true,
        multiple: true,
        extendParams: { type: CURRENT_NODE_MODULE.ABANDON },
        labelName: 'name',
        placeholder: '当前节点',
        searchkeyword: 'keyword',
        apiUrl: 'admin/common/currentNodes'
      },
      { keyword: 'deptId', name: '申请部门', type: 'cascaderSelectWithChild', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      { keyword: 'createDate', name: '创建日期', timeType: 'daterange', type: 'rangeDate' }
    ];
  } else if (type === 7) {
    // 7:员工报销
    const promise = [];
    const map = {};
    setPromiseAndMapArr([
      { name: 'getModuleOurTitle', fn: getModuleOurTitle, params: OUR_TITLE_MODULE.REIMBURSEMENT },
      { name: 'getDepartmentAll', fn: getDepartmentAll }
    ], promise, map);
    if (promise.length) {
      const options = await getOptions(promise);

      if (map['getModuleOurTitle'] !== undefined) {
        options[map['getModuleOurTitle']].data.forEach(i => {
          i.label = i.name; i.value = i.id;
        });
        filterListCache['getModuleOurTitle'] = options[map['getModuleOurTitle']].data;
      }
      if (map['getDepartmentAll'] !== undefined) filterListCache['getDepartmentAll'] = options[map['getDepartmentAll']].data;
    }
    ans.filterList = [
      // 输入框
      { keyword: 'approvalNo', name: '审批单号', labelWidth: '100px', type: 'input' },
      { keyword: 'project', name: '报销项目', labelWidth: '100px', type: 'input' },
      { keyword: 'currentHandler', name: '当前处理人', labelWidth: '100px', type: 'input' },
      { keyword: 'proposer', name: '申请人', labelWidth: '100px', type: 'input' },
      { keyword: 'amount', name: '实付金额', labelWidth: '100px', type: 'inputRange' },
      { keyword: 'creator', name: '创建人', labelWidth: '100px', type: 'input' },
      { keyword: 'comment', name: '评论', type: 'input', labelWidth: '100px' },
      { keyword: 'approvalComment', name: '审批意见', type: 'input', labelWidth: '100px' },
      { keyword: 'totalReimbursementAmount', name: '总报销金额', labelWidth: '100px', type: 'inputRange' },
      { keyword: 'desc', name: '报销说明', labelWidth: '100px', type: 'input' },
      // 下拉
      { keyword: 'type', name: '报销类型', type: 'select', options: [{ value: 0, label: '常规' }, { value: 1, label: '差旅' }] },
      { keyword: 'status', name: '状态', type: 'select', options: commonOptions },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      { keyword: 'departmentIds', name: '申请部门', type: 'cascaderSelectWithChild', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      { keyword: 'attributionMatrixIds', name: '所属部门', type: 'cascaderSelectWithChild', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      { keyword: 'company', name: '所属公司', type: 'select', valueName: 'label', options: filterListCache['getModuleOurTitle'] },
      {
        keyword: 'currentNode',
        name: '当前节点',
        type: 'loadMoreSelect',
        valueName: 'name',
        directShow: true,
        multiple: true,
        extendParams: { type: CURRENT_NODE_MODULE.REIMBURSEMENT },
        labelName: 'name',
        placeholder: '当前节点',
        searchkeyword: 'keyword',
        apiUrl: 'admin/common/currentNodes'
      },
      // 日期
      { keyword: 'createTime', name: '创建时间', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' },
      { keyword: 'planPaymentDate', name: '计划支付日期', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' },
      { keyword: 'actualPaymentDate', name: '实际支付日期', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' }
    ];
  } else if (type === 8) {
    // 8:借款申请
    const promise = [];
    const map = {};
    setPromiseAndMapArr([
      { name: 'getModuleOurTitleLOAN', fn: getModuleOurTitle, params: OUR_TITLE_MODULE.LOAN },
      { name: 'getDepartmentAll', fn: getDepartmentAll }
    ], promise, map);
    if (promise.length) {
      const options = await getOptions(promise);

      if (map['getModuleOurTitleLOAN'] !== undefined) {
        options[map['getModuleOurTitleLOAN']].data.forEach(i => {
          i.label = i.name; i.value = i.id;
        });
        filterListCache['getModuleOurTitleLOAN'] = options[map['getModuleOurTitleLOAN']].data;
      }
      if (map['getDepartmentAll'] !== undefined) filterListCache['getDepartmentAll'] = options[map['getDepartmentAll']].data;
    }
    ans.filterList = [
      // 输入框
      { keyword: 'approvalNum', name: '审批单号', labelWidth: '100px', type: 'input' },
      { keyword: 'remark', name: '借款说明', labelWidth: '100px', type: 'input' },
      { keyword: 'applicant', name: '申请人', labelWidth: '100px', type: 'input' },
      { keyword: 'currentHandler', name: '当前处理人', labelWidth: '100px', type: 'input' },
      { keyword: 'creator', name: '创建人', labelWidth: '100px', type: 'input' },
      { keyword: 'comment', name: '评论', type: 'input', labelWidth: '100px' },
      { keyword: 'approvalComment', name: '审批意见', type: 'input', labelWidth: '100px' },
      { keyword: 'amount', name: '借款金额', labelWidth: '100px', type: 'inputRange',
        isRequired: true, startPlaceholder: '最低金额', endPlaceholder: '最高金额', max: 999999999 },
      // 下拉
      { keyword: 'status', name: '状态', type: 'select', options: commonOptions },
      { keyword: 'company', name: '所属公司', type: 'select', valueName: 'label', options: filterListCache['getModuleOurTitleLOAN'] },
      { keyword: 'applyDepartmentId', name: '申请部门', type: 'cascaderSelectWithChild', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      { keyword: 'subordinateDepartmentId', name: '所属部门', type: 'cascaderSelectWithChild', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      {
        keyword: 'currentNode',
        name: '当前节点',
        type: 'loadMoreSelect',
        valueName: 'name',
        directShow: true,
        multiple: true,
        extendParams: { type: CURRENT_NODE_MODULE.LOAN },
        labelName: 'name',
        placeholder: '当前节点',
        searchkeyword: 'keyword',
        apiUrl: 'admin/common/currentNodes'
      },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      { keyword: 'loanDate', name: '借款周期', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' },
      { keyword: 'createTime', name: '创建时间', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' },
      { keyword: 'planPaymentDate', name: '计划支付日期', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' },
      { keyword: 'actualPaymentDate', name: '实际支付日期', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' }
    ];
  } else if (type === 9) {
    // 9:还款申请
    const promise = [];
    const map = {};
    setPromiseAndMapArr([
      { name: 'getModuleOurTitlePAYBACK', fn: getModuleOurTitle, params: OUR_TITLE_MODULE.PAYBACK },
      { name: 'getDepartmentAll', fn: getDepartmentAll }
    ], promise, map);
    if (promise.length) {
      const options = await getOptions(promise);

      if (map['getModuleOurTitlePAYBACK'] !== undefined) {
        options[map['getModuleOurTitlePAYBACK']].data.forEach(i => {
          i.label = i.name; i.value = i.id;
        });
        filterListCache['getModuleOurTitlePAYBACK'] = options[map['getModuleOurTitlePAYBACK']].data;
      }
      if (map['getDepartmentAll'] !== undefined) filterListCache['getDepartmentAll'] = options[map['getDepartmentAll']].data;
    }
    ans.filterList = [
      // 输入框
      { keyword: 'sn', name: '审批单号', labelWidth: '100px', type: 'input' },
      { keyword: 'description', name: '还款说明', labelWidth: '100px', type: 'input' },
      { keyword: 'backAmount', name: '还款金额', labelWidth: '100px', type: 'inputRange', isRequired: true, startPlaceholder: '最低金额', endPlaceholder: '最高金额', max: 999999999 },
      { keyword: 'proposer', name: '申请人', labelWidth: '100px', type: 'input' },
      { keyword: 'processor', name: '当前处理人', labelWidth: '100px', type: 'input' },
      { keyword: 'createUser', name: '创建人', labelWidth: '100px', type: 'input' },
      { keyword: 'comment', name: '评论', type: 'input', labelWidth: '100px' },
      { keyword: 'approvalComment', name: '审批意见', type: 'input', labelWidth: '100px' },
      // 下拉
      { keyword: 'status', name: '状态', type: 'select', options: commonOptions },
      { keyword: 'ourTitle', name: '所属公司', type: 'select', valueName: 'label', options: filterListCache['getModuleOurTitlePAYBACK'] },
      { keyword: 'proposerDepartmentId', name: '申请部门', type: 'cascaderSelectWithChild', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      { keyword: 'departmentId', name: '所属部门', type: 'cascaderSelectWithChild', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      {
        keyword: 'currentNode',
        name: '当前节点',
        type: 'loadMoreSelect',
        valueName: 'name',
        directShow: true,
        multiple: true,
        extendParams: { type: CURRENT_NODE_MODULE.PAYBACK },
        labelName: 'name',
        placeholder: '当前节点',
        searchkeyword: 'keyword',
        apiUrl: 'admin/common/currentNodes'
      },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      // 日期
      { keyword: 'createTime', name: '创建时间', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' }
    ];
  } else if (type === 11) {
    // 11 转交欠款
    if (!filterListCache['getDepartmentAll']) {
      const options = await getOptions([getDepartmentAll()]);
      filterListCache['getDepartmentAll'] = options[0].data;
    }
    ans.filterList = [
      // 输入框
      { keyword: 'approvalNo', name: '审批单号', labelWidth: '100px', type: 'input' },
      { keyword: 'passer', name: '转交人', labelWidth: '100px', type: 'input' },
      { keyword: 'transferee', name: '被转交人', labelWidth: '100px', type: 'input' },
      { keyword: 'remark', name: '转交说明', labelWidth: '100px', type: 'input' },
      { keyword: 'currentHandler', name: '当前处理人', labelWidth: '100px', type: 'input' },
      { keyword: 'creator', name: '创建人', labelWidth: '100px', type: 'input' },
      {
        keyword: 'amount', name: '转交欠款', labelWidth: '100px', type: 'inputRange',
        isRequired: true, startPlaceholder: '最低金额', endPlaceholder: '最高金额', max: 999999999
      },
      // 下拉
      { keyword: 'status', name: '状态', type: 'select', options: commonOptions },
      {
        keyword: 'departmentIds',
        name: '所属部门',
        type: 'cascaderSelectWithChild',
        childrenVal: 'children',
        options: filterListCache['getDepartmentAll']
      },
      {
        keyword: 'currentNode',
        name: '当前节点',
        type: 'loadMoreSelect',
        valueName: 'name',
        directShow: true,
        multiple: true,
        extendParams: { type: CURRENT_NODE_MODULE.ARREARS_TRANSFER },
        labelName: 'name',
        placeholder: '当前节点',
        searchkeyword: 'keyword',
        apiUrl: 'admin/common/currentNodes'
      },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      { keyword: 'createTime', name: '创建时间', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' }
    ];
  } else if (type === 12) {
    // 12 达人解约
    if (!filterListCache['getDepartmentAll']) {
      const options = await getOptions([getDepartmentAll()]);
      filterListCache['getDepartmentAll'] = options[0].data;
    }
    ans.filterList = [
      // 输入框
      { keyword: 'terminationNum', name: '解约单号', labelWidth: '100px', type: 'input' },
      { keyword: 'terminationExplain', name: '解约说明', labelWidth: '100px', type: 'input' },
      { keyword: 'channelName', name: '供应商名称', labelWidth: '100px', type: 'input' },
      { keyword: 'accountName', name: '账号', labelWidth: '100px', type: 'input' },
      { keyword: 'agentName', name: '签单签约经纪', labelWidth: '100px', type: 'input' },
      { keyword: 'createUser', name: '创建人', labelWidth: '100px', type: 'input' },
      { keyword: 'comment', name: '评论', type: 'input', labelWidth: '100px' },
      // 下拉
      { keyword: 'status', name: '状态', type: 'select', options: commonOptions },
      { keyword: 'departmentId', name: '所属部门', type: 'cascaderSelect', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      {
        keyword: 'currentNode',
        name: '当前节点',
        type: 'loadMoreSelect',
        valueName: 'name',
        directShow: true,
        multiple: true,
        extendParams: { type: CURRENT_NODE_MODULE.TERMINATION },
        labelName: 'name',
        placeholder: '当前节点',
        searchkeyword: 'keyword',
        apiUrl: 'admin/common/currentNodes'
      },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      // 日期
      { keyword: 'terminationTime', name: '解约日期', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' },
      { keyword: 'createTime', name: '创建时间', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' }
    ];
  } else if (type === 13) {
    // 客户额度申请
    const promise = [];
    const map = {};
    setPromiseAndMapArr([
      { name: 'getLevelList', fn: getLevelList },
      { name: 'getDepartmentAll', fn: getDepartmentAll }
    ], promise, map);
    if (promise.length) {
      const options = await getOptions(promise);
      if (map['getLevelList'] !== undefined) {
        options[map['getLevelList']].data.forEach(item => {
          item.label = item.name;
          item.value = item.name;
        });
        filterListCache['getLevelList'] = options[map['getLevelList']].data;
      }
      if (map['getDepartmentAll'] !== undefined) filterListCache['getDepartmentAll'] = options[map['getDepartmentAll']].data;
    }

    ans.filterList = [
      // 输入框
      { keyword: 'approvalNo', name: '审批单号', labelWidth: '85px', type: 'input' },
      { keyword: 'customer', name: '客户名称', labelWidth: '85px', type: 'input' },
      { keyword: 'description', name: '申请说明', labelWidth: '85px', type: 'input' },
      { keyword: 'proposer', name: '申请人', labelWidth: '85px', type: 'input' },
      { keyword: 'creator', name: '创建人', labelWidth: '85px', type: 'input' },
      { keyword: 'currentHandler', name: '当前处理人', labelWidth: '85px', type: 'input' },
      { keyword: 'comment', name: '评论', type: 'input', labelWidth: '85px' },
      { keyword: 'approvalComment', name: '审批意见', type: 'input', labelWidth: '85px' },
      // 下拉框
      { keyword: 'customerLevel', name: '客户等级', type: 'select', valueName: 'value',
        options: filterListCache['getLevelList'] },
      { keyword: 'ranges', name: '申请范围', type: 'select', valueName: 'value', options: [
        { value: 0, label: '调整等级' },
        { value: 1, label: '调整额度' },
        { value: 2, label: '调整账期' }
      ] },
      { keyword: 'status', name: '状态', type: 'select', options: commonOptions },
      {
        keyword: 'applyDepartmentId', name: '申请部门',
        type: 'cascaderSelectWithChild', childrenVal: 'children',
        options: filterListCache['getDepartmentAll']
      },
      {
        keyword: 'subordinateDepartmentId', name: '所属部门',
        type: 'cascaderSelectWithChild', childrenVal: 'children',
        options: filterListCache['getDepartmentAll']
      },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      {
        keyword: 'currentNode',
        name: '当前节点',
        type: 'loadMoreSelect',
        valueName: 'name',
        directShow: true,
        multiple: true,
        extendParams: { type: CURRENT_NODE_MODULE.CUSTOMER_ADJUSTMENT },
        labelName: 'name',
        placeholder: '当前节点',
        searchkeyword: 'keyword',
        apiUrl: 'admin/common/currentNodes'
      },
      // 日期
      { keyword: 'createTime', name: '创建时间', labelWidth: '85px', timeType: 'daterange', type: 'rangeDate' }
    ];
  } else if (type === 14) {
    // 外采额度申请
    if (!filterListCache['getDepartmentAll']) {
      const options = await getOptions([getDepartmentAll()]);
      filterListCache['getDepartmentAll'] = options[0].data;
    }
    ans.filterList = [
      // 输入框
      { keyword: 'sn', name: '审批单号', labelWidth: '100px', type: 'input' },
      { keyword: 'description', name: '申请说明', labelWidth: '100px', type: 'input' },
      { keyword: 'proposerName', name: '申请人', labelWidth: '100px', type: 'input' },
      { keyword: 'authUser', name: '授权人', labelWidth: '100px', type: 'input' },
      { keyword: 'creator', name: '创建人', labelWidth: '100px', type: 'input' },
      { keyword: 'currentHandler', name: '当前处理人', labelWidth: '100px', type: 'input' },
      { keyword: 'comment', name: '评论', type: 'input', labelWidth: '100px' },
      { keyword: 'approvalComment', name: '审批意见', type: 'input', labelWidth: '100px' },
      { keyword: 'applicationAmount', name: '申请外采额度', labelWidth: '100px', type: 'inputRange' },
      { keyword: 'remainingAmount', name: '剩余外采额度', labelWidth: '100px', type: 'inputRange' },
      // 下拉
      { keyword: 'status', name: '状态', type: 'select', options: commonOptions },
      { keyword: 'proposerDepartmentId', name: '申请部门', type: 'cascaderSelectWithChild', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      { keyword: 'attributionMatrix', name: '所属部门', type: 'cascaderSelectWithChild', childrenVal: 'children', options: filterListCache['getDepartmentAll'] },
      {
        keyword: 'currentNode',
        name: '当前节点',
        type: 'loadMoreSelect',
        valueName: 'name',
        directShow: true,
        multiple: true,
        extendParams: { type: CURRENT_NODE_MODULE.EXTERNALHARVEST },
        labelName: 'name',
        placeholder: '当前节点',
        searchkeyword: 'keyword',
        apiUrl: 'admin/common/currentNodes'
      },
      { keyword: 'isExpedited', name: '是否加急', type: 'select', options: expeditedOptions },
      // 日期
      { keyword: 'createTime', name: '创建时间', labelWidth: '100px', timeType: 'daterange', type: 'rangeDate' }
    ];
  }
  return ans;
};

/**
 * 获取配置信息。 在某些情况下，不需要获取 filterList ，也就不需要请求筛选接口，所以抽出这个方法
 */
export const getConfigData = (type) => {
  const data = {
    0: {
      name: '合同审批',
      api: getList,
      fieldsProp: {
        flowCode: { label: '流程编码', minWidth: '100', routerRedirect: (item) => ({
          name: 'contractDetail',
          params: { id: item.id },
          query: { processId: item.processId }
        }) },
        contractName: { label: '项目名称', minWidth: '150' },
        contractCode: { label: '合同编号', minWidth: '130' },
        reviewRole: { label: '待审批角色', minWidth: '120' },
        pendApproval: { label: '待审批人员', minWidth: '120' },
        legalApprover: { label: '法务审批人', minWidth: '135' },
        reviewProgress: { label: '审批进度', minWidth: '120' },
        contractEffectStartDate: { label: '合同日期', width: '210', type: 'contractEffectStartDate' },
        lastAuditTime: { label: '审批时间', minWidth: '150', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' },
        contractType: { label: '合同类型', minWidth: '155', type: 'filter', filter: mapOptions, filterParams: options.typeOptions },
        recycleAttachmentNum: { label: '合同回收', minWidth: '120' },
        creator: { label: '创建人', minWidth: '120' },
        proposer: { label: '申请人', minWidth: '120' },
        oppCompany: { label: '签约对方', minWidth: '120' },
        contractDate: { label: '合作方式', minWidth: '100', type: 'filter', filter: mapOptions, filterParams: options.dateTypeOptions },
        department: { label: '申请人部门', minWidth: '120' },
        archiveCode: { label: '归档编号', minWidth: '120' },
        createTime: { label: '创建时间', minWidth: '120', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' }
      },
      handelParams: (params) => {
        const rangeKeyArr = [{
          attr: 'contractEffectDate',
          start: 'contractEffectStartDate',
          end: 'contractEffectEndDate',
          type: 'round'
        }, {
          attr: 'contractAmount',
          start: 'contractAmountMin',
          end: 'contractAmountMax',
          type: 'moneyFixedTwo'
        }];
        paramsRangeFormat(rangeKeyArr, params);
        paramsAryToStr(['departmentIdList'], params);
      }
    },
    1: {
      name: '付款申请',
      api: getSupplierList,
      fieldsProp: {
        supplierNum: { label: '单号', width: '185', routerRedirect: (item) => ({
          name: 'supplierDetail',
          query: {
            settleId: item.id,
            id: item.supplierId,
            isSettle: true
          }
        }) },
        settleName: { label: '结算名称', width: '240' },
        settlementAmount: { align: 'right', label: '结算金额(元)', width: '130', type: 'price', unit: '分' },
        actualAmount: { align: 'right', label: '实付金额(元)', width: '130', type: 'price', unit: '分' },
        costBelong: { label: '成本来源', width: '120', type: 'filter', filter: supplierCostBelong, condition: { key: 'isNotOrder', value: true, text: '非订单' }},
        reviewRole: { label: '当前节点', width: '120' },
        currentRole: { label: '当前处理人', width: '120' },
        reviewProgress: { label: '审批进度', width: '120' },
        supplier: { label: '供应商', width: '120' },
        status: { label: '状态', type: 'filter', filter: (status) => {
          if (status === undefined || status === null) return '--';
          const statusMap = {
            0: '待提交',
            6: '审批中',
            1: '部分结算',
            2: '未过审',
            3: '已作废',
            4: '已完成',
            5: '已关闭'
          };
          statusMap[-2] = '草稿中';
          return statusMap[status];
        } },
        listStatus: { label: '状态', type: 'filter', filter: (status) => {
          if (status === undefined || status === null) return '--';
          const statusMap = {
            0: '待提交',
            6: '审批中',
            1: '部分结算',
            2: '未过审',
            3: '已作废',
            4: '已完成',
            5: '已关闭'
          };
          statusMap[-2] = '草稿中';
          return statusMap[status];
        } },
        proposerDepartment: { label: '申请人部门', type: 'filter', filter: (data, params, rowItem) => {
          return rowItem ? rowItem.proposerDepartmentName : data;
        }, width: '140' },
        proposerDepartmentName: { label: '申请人部门', width: '140' },
        accountType: { label: '账户类型', width: '120', type: 'filter', filter: accountTypeStatus },
        createTime: { label: '创建时间', minWidth: '140', type: 'date', filter: format, format: 'YYYY/MM/DD' },
        planPayTime: { label: '计划支付日期', minWidth: '140', type: 'date', filter: format, format: 'YYYY/MM/DD' },
        actualPayTime: { label: '实际支付日期', minWidth: '140', type: 'date', filter: format, format: 'YYYY/MM/DD' }
      },
      numberField: [
        { key: 'settlementAmount', name: '结算金额(元)', unit: '分' },
        { key: 'actualAmount', name: '实付金额(元)', unit: '分' }
      ],
      handelParams: (params) => {
        const rangeKeyArr = [{
          attr: 'planPayTime',
          start: 'planPayStartTime',
          end: 'planPayEndTime',
          type: 'time',
          addTime: true
        }, {
          attr: 'actualPayTime',
          start: 'actualPayStartTime',
          end: 'actualPayEndTime',
          type: 'time',
          addTime: true
        }];
        paramsRangeFormat(rangeKeyArr, params);
        paramsAryToStr(['currentNode'], params);
        if (params.settleAmount && Array.isArray(params.settleAmount) && params.settleAmount.length === 2) {
          params.settleAmountBegin = params.settleAmount[0];
          params.settleAmountEnd = params.settleAmount[1];
        }
        delete params.settleAmount;
        if (params.paymentBelong && Array.isArray(params.paymentBelong)) params.paymentBelong = params.paymentBelong.join(',');
      }
    },
    2: {
      name: '精力分配',
      api: energyList,
      fieldsProp: {
        energyNum: { label: '审批单号', minWidth: '150', routerRedirect: (item) => ({
          name: 'energyDetail',
          query: { energyId: item.id, processId: item.processId }
        }) },
        monthTime: { label: '月份', type: 'date', filter: format, format: 'YYYY/MM' },
        status: { label: '状态', type: 'filter', filter: energyStatus },
        proposer: { label: '当前处理人', minWidth: '110' },
        allPersonNum: { label: '填写人数', type: 'allPersonNum' },
        createTime: { label: '创建时间', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' }
      },
      handelParams: (params) => {
        const rangeKeyArr = [
          { attr: 'createTime', start: 'createStartTime', end: 'createEndTime', type: 'time' },
          { attr: 'monthTime', start: 'monthStartTime', end: 'monthEndTime', type: 'time' }
        ];
        paramsRangeFormat(rangeKeyArr, params);
      }
    },
    3: {
      name: '签约内审',
      api: signUpList,
      fieldsProp: {
        signUpNum: { label: '审批单号', minWidth: '150', routerRedirect: (item) => ({
          name: 'signUpDetail',
          query: { signUpId: item.id, processId: item.processId }
        }) },
        supplier: { label: '供应商名称', minWidth: '110' },
        signDate: { label: '签约日期', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD' },
        status: { label: '状态', type: 'filter', filter: energyStatus },
        proposer: { label: '当前处理人', minWidth: '110' },
        createTime: { label: '创建时间', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' }
      },
      handelParams: (params) => {
        const rangeKeyArr = [
          { attr: 'createTime', start: 'createStartTime', end: 'createEndTime', type: 'time' },
          { attr: 'signDate', start: 'signStartTime', end: 'signEndTime', type: 'time' }
        ];
        paramsRangeFormat(rangeKeyArr, params);
      }
    },
    4: {
      name: '申请原件',
      api: getOriginal,
      fieldsProp: {
        sn: { label: '审批单号', minWidth: '150', routerRedirect: (item) => ({
          name: 'originalDetail',
          query: { originalId: item.id, processId: item.processId }
        }) },
        projectName: { label: '项目名称', minWidth: '110' },
        status: { label: '状态', type: 'filter', filter: energyStatus },
        proposer: { label: '当前处理人', minWidth: '110' },
        createTime: { label: '创建时间', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' }
      },
      handelParams: (params) => {
        const rangeKeyArr = [{ attr: 'createTime', start: 'createStartTime', end: 'createEndTime', type: 'time' }];
        paramsRangeFormat(rangeKeyArr, params);
      }
    },
    5: {
      name: '开票申请',
      api: getIssueInvoiceList,
      fieldsProp: {
        approvalNo: { label: '审批单号', minWidth: '150', routerRedirect: (item) => ({
          name: 'issueInvoiceDetail',
          query: { issueId: item.id, processId: item.processId }
        }) },
        invoiceType: { label: '发票类型', width: '174px' },
        taxpayerName: { label: '纳税人名称', width: '286px' },
        ourTitle: { label: '我方抬头', width: '286px' },
        proposer: { label: '申请人', minWidth: '110' },
        amount: { align: 'right', label: '含税金额(元)', minWidth: '130', type: 'price', unit: '分' },
        project: { label: '开票项目', width: '230px' },
        currentNode: { label: '当前节点', minWidth: '110' },
        currentHandler: { label: '当前处理人', minWidth: '110' },
        status: { label: '状态', type: 'filter', filter: energyStatus },
        departmentName: { label: '申请部门', minWidth: '150' },
        createTime: { label: '创建时间', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' }
      },
      numberField: [
        { key: 'amount', name: '含税金额(元)', unit: '分' }
      ],
      handelParams: (params) => {
        const rangeKeyArr = [
          { attr: 'createTime', start: 'createTimeStart', end: 'createTimeEnd', type: 'time', addTime: true },
          { attr: 'amount', start: 'amountStart', end: 'amountEnd', type: 'number' }
        ];
        const arrayKeyArr = ['departmentId', 'currentNode'];
        paramsRangeFormat(rangeKeyArr, params);
        paramsAryToStr(arrayKeyArr, params);
      }
    },
    6: {
      name: '发票作废',
      api: getAbandonList,
      fieldsProp: {
        examineId: { label: '审批单号', minWidth: '150', routerRedirect: (item) => ({
          name: 'invoiceAbandonDetail',
          query: {
            id: item.id,
            processId: item.processId
          }
        }) },
        abandonRemark: { label: '作废说明', minWidth: '140' },
        customerName: { label: '纳税人名称', minWidth: '100' },
        amount: { align: 'right', label: '含税金额(元)', minWidth: '140', type: 'price', unit: '分' },
        proposer: { label: '申请人', minWidth: '100' },
        currentNode: { label: '当前节点', minWidth: '110' },
        currentUser: { label: '当前处理人', minWidth: '110' },
        status: { label: '状态', type: 'filter', filter: energyStatus },
        deptName: { label: '申请部门', minWidth: '110' },
        createTime: { label: '创建时间', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' }
      },
      numberField: [
        { key: 'amount', name: '含税金额(元)', unit: '分' }
      ],
      handelParams: (params) => {
        const rangeKeyArr = [
          { attr: 'createDate', start: 'createDateStart', end: 'createDateEnd', type: 'time', addTime: true },
          { attr: 'amount', start: 'amountStart', end: 'amountEnd', type: 'number' },
          { attr: 'totalReimbursementAmount', start: 'totalReimbursementAmountStart', end: 'totalReimbursementAmountEnd', type: 'number' }
        ];
        const arrayKeyArr = ['currentNode', 'deptId'];
        paramsRangeFormat(rangeKeyArr, params);
        paramsAryToStr(arrayKeyArr, params);
      }
    },
    7: {
      name: '员工报销',
      api: getReimbursementList,
      fieldsProp: {
        approvalNo: { label: '审批单号', minWidth: '130', routerRedirect: (item) => ({
          name: 'reimbursementDetail',
          query: {
            reimbursementId: item.id,
            processId: item.processId
          }
        }) },
        project: { label: '报销项目', width: '180px' },
        type: { label: '报销类型', width: '80px' },
        totalReimbursementAmount: { align: 'right', label: '总报销金额(元)', minWidth: '140', type: 'price', unit: '分' },
        amount: { align: 'right', label: '实付金额(元)', minWidth: '140', type: 'price', unit: '分' },
        proposer: { label: '申请人', minWidth: '110' },
        currentNode: { label: '当前节点', minWidth: '110' },
        currentHandler: { label: '当前处理人', minWidth: '110' },
        status: { label: '状态', type: 'filter', filter: energyStatus },
        departmentName: { label: '申请部门', minWidth: '130' },
        attributionMatrixName: { label: '所属部门', minWidth: '130' },
        createTime: { label: '创建时间', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' },
        planPaymentDate: { label: '计划支付日期', minWidth: '140', type: 'date', filter: format, format: 'YYYY/MM/DD' },
        actualPaymentDate: { label: '实际支付日期', minWidth: '140', type: 'date', filter: format, format: 'YYYY/MM/DD' }
      },
      numberField: [
        { key: 'totalReimbursementAmount', name: '总报销金额(元)', unit: '分' },
        { key: 'amount', name: '实付金额(元)', unit: '分' }
      ],
      handelParams: (params) => {
        const rangeKeyArr = [
          { attr: 'planPaymentDate', start: 'planPaymentStartDate', end: 'planPaymentEndDate', type: 'time', addTime: true },
          { attr: 'actualPaymentDate', start: 'actualPaymentStartDate', end: 'actualPaymentEndDate', type: 'time', addTime: true },
          { attr: 'amount', start: 'amountStart', end: 'amountEnd', type: 'number' },
          { attr: 'totalReimbursementAmount', start: 'totalReimbursementAmountStart', end: 'totalReimbursementAmountEnd', type: 'number' }
        ];
        const arrayKeyArr = ['departmentIds', 'attributionMatrixIds', 'currentNode'];
        paramsRangeFormat(rangeKeyArr, params);
        paramsAryToStr(arrayKeyArr, params);
      }
    },
    8: {
      name: '借款申请',
      api: getLoanList,
      fieldsProp: {
        approvalNum: { label: '审批单号', minWidth: '130', routerRedirect: (item) => ({
          name: 'loanDetail',
          query: {
            id: item.id,
            processId: item.processId
          }
        }) },
        loanStartDate: { label: '借款周期', width: '240', type: 'dateRange', start: 'loanStartDate', end: 'loanEndDate', filter: format, format: 'YYYY/MM/DD' },
        remark: { label: '借款说明', width: '120' },
        amount: { align: 'right', label: '借款金额(元)', minWidth: '140', type: 'price', unit: '分' },
        currentHandler: { label: '当前处理人', minWidth: '150' },
        status: { label: '状态', type: 'filter', filter: energyStatus },
        createTime: { label: '创建时间', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' },
        planPaymentDate: { label: '计划支付日期', minWidth: '140', type: 'date', filter: format, format: 'YYYY/MM/DD' },
        actualPaymentDate: { label: '实际支付日期', minWidth: '140', type: 'date', filter: format, format: 'YYYY/MM/DD' }
      },
      numberField: [{ key: 'amount', name: '借款金额(元)', unit: '分' }],
      handelParams: (params) => {
        // 设置tab
        const rangeKeyArr = [
          { attr: 'loanDate', start: 'loanStartDate', end: 'loanEndDate', type: 'time', addTime: true },
          { attr: 'planPaymentDate', start: 'planPaymentStartDate', end: 'planPaymentEndDate', type: 'time', addTime: true },
          { attr: 'actualPaymentDate', start: 'actualPaymentStartDate', end: 'actualPaymentEndDate', type: 'time', addTime: true },
          { attr: 'createTime', start: 'createStartTime', end: 'createEndTime', type: 'time', addTime: true },
          { attr: 'amount', start: 'amountStart', end: 'amountEnd', type: 'moneyFixed' }
        ];
        const arrayKeyArr = ['applyDepartmentId', 'subordinateDepartmentId', 'currentNode'];
        paramsRangeFormat(rangeKeyArr, params);
        paramsAryToStr(arrayKeyArr, params);
      }
    },
    9: {
      name: '还款申请',
      api: payBackList,
      fieldsProp: {
        'sn': { minWidth: '150', routerRedirect: (item) => ({
          name: 'payBackDetail',
          query: {
            id: item.id,
            processId: item.processId
          }
        }) },
        'description': { label: '还款说明', minWidth: '130' },
        'backAmount': { align: 'right', label: '还款金额(元)', minWidth: '130', type: 'price', unit: '分' },
        'proposer': { label: '申请人', minWidth: '110' },
        'processor': { label: '当前处理人', minWidth: '110' },
        'status': { label: '状态', type: 'filter', filter: energyStatus },
        'createTime': { label: '创建时间', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' }
      },
      numberField: [{ key: 'backAmount', name: '还款金额(元)', unit: '分' }],
      handelParams: (params) => {
        const rangeKeyArr = [
          { attr: 'createTime', start: 'createStartTime', end: 'createEndTime', type: 'time', addTime: true },
          { attr: 'backAmount', start: 'backAmountMin', end: 'backAmountMax', type: 'moneyFixed' }
        ];
        paramsRangeFormat(rangeKeyArr, params);
        Object.keys(params).forEach(key => {
          if (params[key] && Array.isArray(params[key])) {
            params[key] = params[key].join(',');
          }
        });
      }
    },
    11: {
      name: '转交欠款',
      api: getArrearsTransferList,
      fieldsProp: {
        approvalNo: { label: '审批单号', minWidth: '150', routerRedirect: (item) => ({
          name: 'arrearsTransferDetail',
          query: {
            id: item.id,
            processId: item.processId
          }
        }) },
        passer: { label: '转交人', minWidth: '120' },
        amount: { align: 'right', label: '转交欠款(元)', minWidth: '140', type: 'price', unit: '分' },
        transferee: { label: '被转交人', minWidth: '120' },
        currentHandler: { label: '当前处理人', minWidth: '150' },
        status: { label: '状态', type: 'filter', filter: energyStatus },
        createTime: { label: '创建时间', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' }
      },
      numberField: [
        { key: 'amount', name: '转交欠款(元)', unit: '分' }
      ],
      handelParams: (params) => {
        const rangeKeyArr = [{
          attr: 'createTime',
          start: 'createStartTime',
          end: 'createEndTime',
          type: 'time',
          addTime: true
        }, {
          attr: 'amount',
          start: 'amountStart',
          end: 'amountEnd',
          type: 'moneyFixed'
        }];
        const arrayKeyArr = ['departmentIds', 'currentNode'];
        paramsRangeFormat(rangeKeyArr, params);
        paramsAryToStr(arrayKeyArr, params);
      }
    },
    // 达人解约
    12: {
      name: '达人解约',
      api: terminationList,
      fieldsProp: {
        terminationNum: { label: '解约单号', minWidth: '150', routerRedirect: (item) => ({
          name: 'terminationDetail',
          query: {
            terminationId: item.id,
            processId: item.processId
          }
        }) },
        terminationExplain: { label: '解约说明', minWidth: '200' },
        accounts: { label: '账号', minWidth: '110' },
        channelName: { label: '供应商名称', minWidth: '110' },
        agentName: { label: '签单签约经纪', minWidth: '110' },
        currentHandler: { label: '当前处理人', minWidth: '150' },
        currentNode: { label: '当前节点', minWidth: '110' },
        department: { label: '所属部门', minWidth: '120' },
        createUserId: { label: '创建人', minWidth: '120' },
        status: { label: '状态', type: 'filter', filter: energyStatus },
        terminationTime: { label: '解约日期', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD' },
        createTime: { label: '创建时间', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' }
      },
      handelParams: (params) => {
        const rangeKeyArr = [{
          attr: 'createTime',
          start: 'createStartTime',
          end: 'createEndTime',
          type: 'time'
        }, {
          attr: 'terminationTime',
          start: 'terminationStartTime',
          end: 'terminationEndTime',
          type: 'time'
        }];
        paramsRangeFormat(rangeKeyArr, params);
        paramsAryToStr(['currentNode'], params);
      }
    },
    // 客户额度申请
    13: {
      name: '客户调额申请',
      api: getClientAdjustmentList,
      fieldsProp: {
        approvalNo: { label: '审批单号', minWidth: '150', routerRedirect: (item) => ({
          name: 'customerAdjustmentDetail',
          query: {
            id: item.id,
            processId: item.processId,
            fromList: 1
          }
        }) },
        customer: { label: '客户名称', minWidth: '120' },
        customerLevel: { label: '客户等级', minWidth: '120', type: 'customerLevel' },
        description: { label: '申请说明', minWidth: '120' },
        ranges: { label: '申请范围', minWidth: '120' },
        proposer: { label: '申请人', minWidth: '120' },
        currentHandler: { label: '当前处理人', minWidth: '150' },
        currentNode: { label: '当前节点', minWidth: '110' },
        status: { label: '状态', type: 'filter', filter: energyStatus },
        creator: { label: '创建人', minWidth: '110' },
        proposerDepartment: { label: '申请部门', minWidth: '150' },
        subordinateDepartment: { label: '所属部门', minWidth: '150' },
        createTime: { label: '创建时间', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' }
      },
      handelParams: (params) => {
        const rangeKeyArr = [
          {
            attr: 'createTime',
            start: 'createStartTime',
            end: 'createEndTime',
            type: 'time',
            addTime: true
          }
        ];
        paramsRangeFormat(rangeKeyArr, params);
        paramsAryToStr(['applyDepartmentId', 'subordinateDepartmentId', 'currentNode'], params);
      }
    },
    // 外采额度申请
    14: {
      name: '外采额度申请',
      api: externalHarvestList,
      fieldsProp: {
        sn: { label: '审批单号', minWidth: '150', routerRedirect: (item) => ({
          name: 'externalHarvestDetail',
          query: {
            id: item.id,
            processId: item.processId,
            fromList: 1
          }
        }) },
        proposerName: { label: '申请人', minWidth: '120' },
        applicationAmount: { label: '申请外采额度', minWidth: '200', type: 'filter', filter: (num) => moneyFilter(num, true, '', true) },
        remainingAmount: { label: '剩余外采额度', minWidth: '110', type: 'filter', filter: (num) => moneyFilter(num, true, '', true) },
        description: { label: '申请说明', minWidth: '110' },
        authUser: { label: '授权人', minWidth: '110' },
        currentHandler: { label: '当前处理人', minWidth: '150' },
        currentNode: { label: '当前节点', minWidth: '110' },
        status: { label: '状态', type: 'filter', filter: energyStatus },
        createUser: { label: '创建人', minWidth: '110' },
        proposerDepartment: { label: '申请部门', minWidth: '120' },
        attributionMatrixName: { label: '所属部门', minWidth: '120' },
        createTime: { label: '创建时间', minWidth: '160', type: 'date', filter: format, format: 'YYYY/MM/DD HH:mm' }
      },
      numberField: [
        { key: 'applicationAmount', name: '申请外采额度' },
        { key: 'remainingAmount', name: '剩余外采额度' }
      ],
      handelParams: (params) => {
        const rangeKeyArr = [
          {
            attr: 'createTime',
            start: 'createStartTime',
            end: 'createEndTime',
            type: 'time'
          },
          {
            attr: 'applicationAmount',
            start: 'applicationAmountMin',
            end: 'applicationAmountMax',
            type: 'number'
          },
          {
            attr: 'remainingAmount',
            start: 'remainingAmountMin',
            end: 'remainingAmountMax',
            type: 'number'
          }
        ];
        paramsRangeFormat(rangeKeyArr, params);
        paramsAryToStr(['currentNode', 'attributionMatrix', 'proposerDepartmentId'], params);
      }
    }
  };
  return data[type] || null;
};
